Skip to content

Comments

feat(cli): add option to override existing files during installation#8

Merged
activadee merged 3 commits intomainfrom
OW/OW-3-add-cli-option-to-override-existing-files
Jan 3, 2026
Merged

feat(cli): add option to override existing files during installation#8
activadee merged 3 commits intomainfrom
OW/OW-3-add-cli-option-to-override-existing-files

Conversation

@activadee
Copy link
Owner

Summary

  • Add CLI option to override existing workflow files and skills during installation without interactive prompts
  • Update installer logic to check for existing files and handle override behavior with safety mechanisms
  • Extend CLI interface with new flag and user input handling for override scenarios
  • Add comprehensive test coverage for the new override functionality
  • Update README with documentation and examples for the new CLI option

### Changes Made

**1. src/cli/installer.ts**
- Added 'overwritten' status to InstallResult.status type
- Added overrideNames?: Set<string> to InstallOptions for granular per-file overrides
- Updated installWorkflows, installSkills, installAuthWorkflow to accept override?: boolean and handle overwriting
- Added helper functions: checkExistingWorkflows, checkExistingSkills, checkExistingAuthWorkflow

**2. src/cli/index.ts**
- Added --force / -f flag parsing
- Added interactive per-file override prompts using @clack/prompts
- Updated output to show overwritten files with cyan ◆ symbol
- Updated help text with --force flag documentation

**3. README.md**
- Added --force flag to CLI options
- Added "Override Behavior" section documenting the feature

**4. test/installer.test.js**
- Added 13 new tests covering:
 - Creating new files
 - Skipping existing files without override
 - Overwriting with override: true
 - Per-file overrides with overrideNames
 - checkExisting* helper functions

### Verification
- ✅ bun run typecheck - No errors
- ✅ bun run test - 21 tests pass
- ✅ bun run build - Builds successfully
- ✅ lsp_diagnostics - No issues in changed files

Attempt: att-3d3bc718-a692-482a-9026-78b95e496d13
Profile: apg-70541e2b-d01c-4d50-a814-7025ac222ebe
@github-actions
Copy link
Contributor

github-actions bot commented Jan 3, 2026

AI Review Summary

Verdict: REQUEST CHANGES
Commit: 7cc3b31

Findings

  • [MEDIUM] src/cli/index.ts:122 – Potential race condition with async confirm in loop
    • The loop uses await inside a for...of loop to prompt for each file sequentially. While this works, if a user cancels mid-way through, the skillOverrides and workflowOverrides sets will be partially populated. This could lead to unexpected behavior where some files are marked for override but the installation is cancelled. Consider wrapping the entire loop in a try-catch or checking for cancellation before proceeding to installation.

    • Suggested fix:

      for (const file of existingFiles) {
        const shouldOverride = await p.confirm({
          message: `Override ${file.path}?`,
          initialValue: false,
        });
      
        if (p.isCancel(shouldOverride)) {
          p.cancel('Installation cancelled.');
          process.exit(0);
        }
      
        if (shouldOverride) {
          if (file.type === 'skill') {
            skillOverrides.add(file.name);
          } else if (file.type === 'workflow') {
            workflowOverrides.add(file.name);
          } else if (file.type === 'auth') {
            overrideAuth = true;
          }
        }
      }
      
  • [MEDIUM] src/cli/index.ts:105 – checkExistingSkills called without filtering by selected workflows
    • When --workflows flag is used without --skills, the code still checks for ALL existing skills (line 105) even though skills won't be installed. This could prompt users to override skill files that won't actually be touched. The check should be skipped entirely when isWorkflowsOnly is true, which it already is on line 104, but the logic seems correct. However, when isSkillsOnly is true, line 109 checks workflows that won't be installed. This is inconsistent behavior.

    • Suggested fix:

      if (!isWorkflowsOnly) {
        existingFiles.push(...checkExistingSkills({}));
      }
      
      if (!isSkillsOnly) {
        existingFiles.push(...checkExistingWorkflows({ workflows: selectedWorkflows }));
        if (useOAuth) {
          const authFile = checkExistingAuthWorkflow({});
          if (authFile) {
            existingFiles.push(authFile);
          }
        }
      }
      

Overall Assessment

This PR adds a well-designed --force flag and interactive override prompts for existing files during installation. The implementation is solid with comprehensive test coverage. However, there are two medium-severity issues: a potential race condition in the interactive prompt loop and inconsistent handling of the --force flag when combined with --skills or --workflows options.

@activadee activadee merged commit 1de5a6b into main Jan 3, 2026
@activadee activadee deleted the OW/OW-3-add-cli-option-to-override-existing-files branch January 3, 2026 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant